import { BasePageQuery } from '../base/Base'
import { momentToString } from '@/utils/date'
import { Moment } from 'moment'

export class RolePageQuery extends BasePageQuery {
  name?: string
  createTimeStart?: String
  createTimeEnd?: String
  syncCreateTime(createTime: Moment[]): void {
    if (!createTime?.length) {
      this.createTimeStart = undefined
      this.createTimeEnd = undefined
      return
    }
    this.createTimeStart = momentToString(createTime[0])
    if (createTime?.length !== 2) {
      this.createTimeEnd = undefined
      return
    }
    this.createTimeEnd = momentToString(createTime[1])
  }
}

export interface RolePageList {
  id: number
  name: string
  storeId: number
  createTime: Date
  updateTime: Date
}

export interface RolePageRes {
  current: number
  size: number
  total: number
  records: Array<RolePageList>
}
